<?php include("mainlist.php");?>
<table cellspacing="0" border="0" width="995">
	<tr>
		<td width="200" valign="top">					
			<?php
				include("menuleftcategory.php");
			?>
		</td>	
		<td width="790" valign="top">
			<table cellspacing="0" border="0" width="790">
				<tr>
				<?php
					$id=$_GET['id'];
					
					$querycat="SELECT * FROM categories WHERE id=$id";
					$resultcat = mysql_query($querycat) or die(mysql_error());
					while($rowscat = mysql_fetch_array($resultcat)){?>
						<td width="790" class="title_manager_cate"><?php echo $rowscat['cateName'];?></td>
				<?php
				}
				?>	
				</tr>
			</table>
			<table cellspacing="0" cellpadding="0" border="0" width="790">
				<?php
						//$id=$_GET['id'];
						
						//$query="SELECT * FROM groupcategories WHERE cateID=$id";
						//$result=mysql_query($query) or die(mysql_error());
						//while($rows = mysql_fetch_array($result)){?>
						<tr><td height="10" bordercolor="#FFFFFF"></td></tr>
						<!--<tr>
							<td class="productadmintitle">
								<table border="0" cellspacing="0" cellpadding="0" width="790">
									<tr>
										<td><?php echo $rows['groupName'];?></td>
										<td align="right"><a href="index.php?admin=productAdmin&do=formeditgroup&id=<?php echo $rows['id'];?>"><img src="images/edit.gif" width="17" height="17" border="0" /></a>
										<a href="index.php?admin=productAdmin&do=deletegroup&id=<?php echo $rows['id'];?>" onclick="return confirm('Bạn có muốn xoá nhóm sản phẩm này không?');"><img src="images/delete.gif" width="17" height="17" border="0" /></a></td>
									</tr>
								</table>
							</td>	
						</tr>-->
						
						<tr>
							<td>
								<table class="reference" cellspacing="0" cellpadding="0" border="0" width="790">
									<tr>
										<td width="10" class="listgrouptitle"><b>Stt</b></td>
										<td width="480" class="listgrouptitle"><b>Tên File</b></td>
										<td width="70" class="listgrouptitle"><b>Trạng thái</b></td>
										<td width="150" class="listgrouptitle"><b>Ngày khởi tạo</b></td>
										<td width="80" class="listgrouptitle"><b>Chức năng</b></td>
									</tr>
									<tr>
										<?php
										$i=1;
										//TrungDQ- Get productID from categories_products table
										$query_cate_pro="select * from categories_products where categoryId=$id ORDER BY id DESC ";
										$cate_pro_result = mysql_query($query_cate_pro);
										while($the_cate_pro_result = mysql_fetch_array($cate_pro_result))
										{
											$productID =  $the_cate_pro_result['productId'];
											
											$querypro = "SELECT * FROM productdetails WHERE id = $productID";
											$resultpro = mysql_query($querypro) or die(mysql_error());
											
											$a=1;
											
											while($rowspro = mysql_fetch_array($resultpro)){
											//print_r($rowspro);
												//if($rowscat['id']==$rowspro['cateID']){
											?>
											<td><?php echo $i++; ?></td>	
											<td><?php echo $rowspro['productname'];?></td>
											<td><?php
												if($rowspro['state']=="on"){
													echo "Hiện";
												}else{
													echo "Ẩn";
												}
											?></td>	
											<td><?php $ngay = date('d/m/Y', $rowspro['dateCreated']); echo $ngay;?></td>
											<td>
												<table border="0" align="center">
													<tr>
														<td><a href="index.php?admin=productAdmin&do=formeditproduct&id=<?php echo $rowspro[0];?>&type=<?php echo $id ?>"><img src="images/edit.gif" width="17" height="17" border="0" /></a></td>
														<td><a href="index.php?admin=productAdmin&do=deleteproduct&id=<?php echo $rowspro[0];?>" onclick="return confirm('Bạn có muốn xoá sản phẩm không?');"><img src="images/delete.gif" width="17" height="17" border="0" /></a></td>
													</tr>
												</table>
											</td>
										 <?php
											if($a%1==0){
												echo "<tr></tr>";	
											}
											$a=$a+1;
											//}
										   }
										}  
										?>
									</tr>
								</table>
							</td>
						</tr>
					<?php
					//}
					?>    
			</table>
		</td>
	</tr>	
</table>